#include "StatusLayer.h"
#include "GlobalDefine.h"

bool StatusLayer::init()
{
    if (!CCLayer::init())
        return false;
    
    coins = 0;
    this->setTag(1);
   
	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();

    this->labelCoin = CCLabelTTF::create("Coins: 0", "Arial", 30);
	this->labelCoin->setPosition(ccp(100, visibleSize.height - 20));
    this->addChild(this->labelCoin);
    
    this->labelMeter = CCLabelTTF::create("Meter: 0", "Arial", 30);
    this->labelMeter->setPosition(ccp(300, visibleSize.height - 20));
    this->addChild(this->labelMeter);
    
    return true;
}

void StatusLayer::addCoin(int num)
{
    coins += num;
	g_coins = coins;
    this->labelCoin->setString(CCString::createWithFormat("Coins: %ld",coins)->getCString());
}

void StatusLayer::updateMeter(int px)
{
	g_scores = px/10;
    this->labelMeter->setString(CCString::createWithFormat("%d: %s", px/10, "m")->getCString());
}